package com.ruoyi.web.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.order.domain.MesManufacturer;
import com.ruoyi.order.service.IMesManufacturerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 制造商信息Controller
 * 
 * @author guoxl
 * @date 2025-04-30
 */
@RestController
@RequestMapping("/order/manufacturer")
public class MesManufacturerController extends BaseController
{
    @Autowired
    private IMesManufacturerService mesManufacturerService;

    /**
     * 查询制造商信息列表
     */
    @PreAuthorize("@ss.hasPermi('order:manufacturer:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesManufacturer mesManufacturer)
    {
        startPage();
        List<MesManufacturer> list = mesManufacturerService.selectMesManufacturerList(mesManufacturer);
        return getDataTable(list);
    }

    /**
     * 导出制造商信息列表
     */
    @PreAuthorize("@ss.hasPermi('order:manufacturer:export')")
    @Log(title = "制造商信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesManufacturer mesManufacturer)
    {
        List<MesManufacturer> list = mesManufacturerService.selectMesManufacturerList(mesManufacturer);
        ExcelUtil<MesManufacturer> util = new ExcelUtil<MesManufacturer>(MesManufacturer.class);
        util.exportExcel(response, list, "制造商信息数据");
    }

    /**
     * 获取制造商信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:manufacturer:query')")
    @GetMapping(value = "/{manufacturerId}")
    public AjaxResult getInfo(@PathVariable("manufacturerId") Long manufacturerId)
    {
        return success(mesManufacturerService.selectMesManufacturerByManufacturerId(manufacturerId));
    }

    /**
     * 新增制造商信息
     */
    @PreAuthorize("@ss.hasPermi('order:manufacturer:add')")
    @Log(title = "制造商信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesManufacturer mesManufacturer)
    {
        return toAjax(mesManufacturerService.insertMesManufacturer(mesManufacturer));
    }

    /**
     * 修改制造商信息
     */
    @PreAuthorize("@ss.hasPermi('order:manufacturer:edit')")
    @Log(title = "制造商信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesManufacturer mesManufacturer)
    {
        return toAjax(mesManufacturerService.updateMesManufacturer(mesManufacturer));
    }

    /**
     * 删除制造商信息
     */
    @PreAuthorize("@ss.hasPermi('order:manufacturer:remove')")
    @Log(title = "制造商信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{manufacturerIds}")
    public AjaxResult remove(@PathVariable Long[] manufacturerIds)
    {
        return toAjax(mesManufacturerService.deleteMesManufacturerByManufacturerIds(manufacturerIds));
    }
}
